﻿@using MyApp1.Models;
@{
    ViewBag.Title = "SaveEmail";
    List<Customer> customers = ViewData["MY.CUSTOMER.LIST"] as List<Customer>;
    Layout = null;
}

<h2>SaveEmail</h2>

Server Time Is: @DateTime.Now.ToString("dd MMMM, yyyy hh:mm::ss")
@if (customers != null && customers.Count > 0) { 
    for (int i = 0; i < customers.Count; i++)
    {
        Customer customer = customers[i];
        <div style="margin-top:10px;">
            <div><strong>Customer ID:</strong> @customer.ID</div>
            <div><strong>Customer Name:</strong> @customer.Name</div>
        </div>
    }
}

<form method="post" action="/Vizrt/SaveEmail">
    <table>
        <tr>
            <td><input id="TextEmail" name="CustomerEmail" type="text" value="" style="width:220px;color:gray;" /></td>
        </tr>
        <tr>
            <td><input id="TextEmail" type="submit" value="Submit" style="width:80px;float:right;" /></td>
        </tr>
    </table>
    <button type="button" value="Get Time from Server" onclick="SendAjaxRequest();">Get Time from Server</button>
</form>


<script language="javascript" type="text/javascript">

    function SendAjaxRequest()
    {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                //document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
                alert('Server Response Is: ' + xmlhttp.responseText);
            }
        }

        xmlhttp.open("POST", "/Vizrt/GetServerTime", true);
        xmlhttp.send();
    }
</script>